package business;

/**
 * 
 * @author Antonio Sequeira 2011
 *
 */
public class PessoaPrototype implements Cloneable{

	private String nome;
	private CalendarDate dataNascimento;
	private String email;

	/***********************************************************
	 * 
	 ***********************************************************/
	public PessoaPrototype()
	{	 
		super();
	}

	/***********************************************************
	 * @param nome
	 * @param dataNascimento
	 * @param email
	 ***********************************************************/
	public PessoaPrototype(String nome, CalendarDate dataNascimento, String email)
	{

		assert (nome != null && dataNascimento != null && email != null); 
		this.nome = nome;
		this.dataNascimento = dataNascimento;
		this.email = email;
		assert this.idade() > 0 && this.idade() < 140;
	}

	/***********************************************************
	 * @return the nome
	 ***********************************************************/
	public String getNome()
	{
		return nome;
	}

	/***********************************************************
	 * @return the dataNascimento
	 ***********************************************************/
	public CalendarDate getDataNascimento()
	{
		return dataNascimento;
	}

	/***********************************************************
	 * @return the email
	 ***********************************************************/
	public String getEmail()
	{
		return email;
	}

	/***********************************************************
	 * @param nome
	 *            the nome to set
	 ***********************************************************/
	public void setNome(String nome)
	{
		assert nome != null: "nome invalido";
		this.nome = nome;
	}

	/***********************************************************
	 * @param dataNascimento
	 *            the dataNascimento to set
	 ***********************************************************/
	public void setDataNascimento(CalendarDate dataNascimento)
	{
		this.dataNascimento = dataNascimento;
	}

	/***********************************************************
	 * @param email
	 *            the email to set
	 ***********************************************************/
	public void setEmail(String email)
	{
		this.email = email;
	}

	/***********************************************************
	 * @return Pessoa's age
	 ***********************************************************/
	public int idade()
	{
		assert dataNascimento != null;
		return CalendarDate.today().yearsSince(dataNascimento);
	}

	public Object clone(){
		try{
			return super.clone();
		}catch(Exception e){
			System.err.println(e.getMessage());
			return null;
		}
	}
}
